﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App12
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }
    }

    public class MainPageViewModel : BindableBase
    {
        public MainPageViewModel()
        {
            this._Letters = new ObservableCollection<string>(new[] { "A", "B", "C", "D" });
            this._Numbers = new ObservableCollection<int>(new[] { 1, 2, 3, 4 });
        }

        public string Letter
        {
            get { return (string)GetValue(LetterProperty); }
            set
            {
                SetValue(LetterProperty, value);
                base.RaisePropertyChanged();
            }
        }
        public static readonly DependencyProperty LetterProperty =
            DependencyProperty.Register("Letter", typeof(string), typeof(MyControlViewModel),
            new PropertyMetadata("Z", (s, e) => { }));

        ObservableCollection<string> _Letters = new ObservableCollection<string>();
        public ObservableCollection<string> Letters { get { return _Letters; } }

        ObservableCollection<int> _Numbers = new ObservableCollection<int>();
        public ObservableCollection<int> Numbers { get { return _Numbers; } }
    }

    public abstract class BindableBase : DependencyObject, System.ComponentModel.INotifyPropertyChanged
    {

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        protected void SetProperty<T>(ref T storage, T value, [System.Runtime.CompilerServices.CallerMemberName] String propertyName = null)
        {
            if (!object.Equals(storage, value))
            {
                storage = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
        protected void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] String propertyName = null)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }
}
